@objectstack/runtime 12.3.0 → 12.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +22 -22
package/dist/index.cjs
CHANGED
|
@@ -4040,6 +4040,35 @@ var _HttpDispatcher = class _HttpDispatcher {
|
|
|
4040
4040
|
if (!pkg) return { handled: true, response: this.error(`Package '${id}' not found`, 404) };
|
|
4041
4041
|
return { handled: true, response: this.success(pkg) };
|
|
4042
4042
|
}
|
|
4043
|
+
if (parts.length === 1 && m === "PATCH") {
|
|
4044
|
+
const id = decodeURIComponent(parts[0]);
|
|
4045
|
+
const src = (body?.manifest && typeof body.manifest === "object" ? body.manifest : body) ?? {};
|
|
4046
|
+
const patch = {};
|
|
4047
|
+
if (typeof src.name === "string") patch.name = src.name.trim();
|
|
4048
|
+
if (typeof src.description === "string") patch.description = src.description;
|
|
4049
|
+
if (typeof src.version === "string") patch.version = src.version.trim();
|
|
4050
|
+
if (patch.name !== void 0 && patch.name === "") {
|
|
4051
|
+
return { handled: true, response: this.error("name must not be empty", 400) };
|
|
4052
|
+
}
|
|
4053
|
+
if (patch.version !== void 0 && !/^\d+\.\d+\.\d+$/.test(patch.version)) {
|
|
4054
|
+
return { handled: true, response: this.error("version must be semantic (e.g. 1.0.0)", 400) };
|
|
4055
|
+
}
|
|
4056
|
+
if (patch.name === void 0 && patch.description === void 0 && patch.version === void 0) {
|
|
4057
|
+
return { handled: true, response: this.error("Body { name?, description?, version? } \u2014 nothing to update", 400) };
|
|
4058
|
+
}
|
|
4059
|
+
const protocol = await this.resolveService("protocol");
|
|
4060
|
+
if (protocol && typeof protocol.updatePackage === "function") {
|
|
4061
|
+
try {
|
|
4062
|
+
const updated = await protocol.updatePackage({ packageId: id, patch });
|
|
4063
|
+
return { handled: true, response: this.success(updated?.package ?? updated) };
|
|
4064
|
+
} catch (e) {
|
|
4065
|
+
return { handled: true, response: this.error(e.message, e.statusCode || 500) };
|
|
4066
|
+
}
|
|
4067
|
+
}
|
|
4068
|
+
const pkg = registry.updatePackageManifest(id, patch);
|
|
4069
|
+
if (!pkg) return { handled: true, response: this.error(`Package '${id}' not found`, 404) };
|
|
4070
|
+
return { handled: true, response: this.success(pkg) };
|
|
4071
|
+
}
|
|
4043
4072
|
if (parts.length === 1 && m === "DELETE") {
|
|
4044
4073
|
const id = decodeURIComponent(parts[0]);
|
|
4045
4074
|
const registryRemoved = registry.uninstallPackage(id);
|